package com.miniotest.Config;
 
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
 
 
@Configuration //标志着这是一个配置类
@EnableSwagger2WebMvc
public class SwaggerConfig {
 
//  http://localhost:8881/doc.html#/home
    @Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.miniotest.Controller"))//对应你controller目录
                .paths(PathSelectors.any())
                .build();
    }
 
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("swagger 接口文档")  //指定文档标题
                .contact(new Contact("作者名字", "url", "你的邮箱"))  //指定作者
                .description("swagger接口文档描述")  //接口文档描述
                .license("Apache License Version 2.0")  //许可
                .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0.html") //许可链接
                .termsOfServiceUrl("http://localhost:8881") //指定在线接口文档访问url
                .version("1.0")  //指定版本号
                .build();
    }
}